var jsdDatas = [
    { "id": "1174448", "title": "嘉实多磁护全合成机油 SN/CF 5W40 1L", "price": "72", "img_src": "image/CH-5W-40-1L-s.jpg" },
    { "id": "1174446", "title": "嘉实多极护钛流体强化全合成机油 SN.A5/B5 5W30 1L", "price": "80", "img_src": "image/JH-5W-30-1L-s.jpg" },
    { "id": "1174441", "title": "嘉实多极护钛流体强化全合成机油 SN.A3/B4 5W40 1L", "price": "80", "img_src": "image/JH-5W-40-1L-s.jpg" },
    { "id": "1174447", "title": "嘉实多磁护全合成机油 SN/CF 5W40 4L", "price": "268", "img_src": "image/CH-5W-40-4L-s.jpg" },
    { "id": "1174445", "title": "嘉实多极护钛流体强化全合成机油 SN.A5/B5 5W30 4L", "price": "320", "img_src": "image/JH-5W-30-4L-s.jpg" },
    { "id": "1174437", "title": "嘉实多极护钛流体强化全合成机油 SN.A3/B4 5W40 4L", "price": "320", "img_src": "image/JH-5W-40-4L-s.jpg" }

]

var amDatas = [
    { "id": "1174508", "title": "安美A7 全合成汽油机油 SN 5W-30 1L", "price": "48", "oprice": "80", "img_src": "image/A7-5W-30-1L-s.jpg" },
    { "id": "1174507", "title": "安美A7 全合成汽油机油 SN 5W-40 1L", "price": "48", "oprice": "80", "img_src": "image/A7-5W-40-1L-s.jpg" },
    { "id": "1174459", "title": "安美A7 全合成汽油机油 SN 5W-30 4L", "price": "220.8", "oprice": "368", "img_src": "image/A7-5W-30-4L-s.jpg" },
    { "id": "1174458", "title": "安美A7 全合成汽油机油 SN 5W-40 4L", "price": "220.8", "oprice": "368", "img_src": "image/A7-5W-40-4L-s.jpg" },
    { "id": "1174460", "title": "安美A6 合成技术汽油机油 SN 10W-40 4L", "price": "154.8", "oprice": "258", "img_src": "image/A6-10W-40-4L-s.jpg" }

]

// 2.实例Vue对象
new Vue({
    el: '.g-box',
    data: {
        jsdData: jsdDatas,
        amData: amDatas
    },
    methods: {
        // APP端接口
        getApp: function(key, value) {
            var appData = { "key": key, "value": value };
            // alert("key值是:"+key+",vlaue值是:"+value);
            //判断访问终端
            var browser = {
                versions: function() {
                    var u = navigator.userAgent,
                        app = navigator.appVersion;
                    return {
                        trident: u.indexOf('Trident') > -1, //IE内核
                        presto: u.indexOf('Presto') > -1, //opera内核
                        webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
                        gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
                        mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
                        ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
                        android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
                        iPhone: u.indexOf('iPhone') > -1, //是否为iPhone或者QQHD浏览器
                        iPad: u.indexOf('iPad') > -1, //是否iPad
                        webApp: u.indexOf('Safari') == -1, //是否web应该程序，没有头部与底部
                        weixin: u.indexOf('MicroMessenger') > -1, //是否微信 （2015-01-22新增）
                        qq: u.match(/\sQQ/i) == " qq" //是否QQ
                    };
                }(),
                language: (navigator.browserLanguage || navigator.language).toLowerCase()
            }

            // 判断是安卓还是苹果
            if (browser.versions.android) {
                getAppData(JSON.stringify(appData));
            } else {
                var iver = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
                iver = parseInt(iver[1], 10);
                // IOS 8以上用webkit方法,IOS 8以下用UIWebview方法
                if (iver >= 8) {
                    // AppModel是OC所注入的对象
                    window.webkit.messageHandlers.AppModel.postMessage({ body: appData });
                } else {
                    getAppData(appData);
                }
            }
        }
    }
})